home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / util / time / backclock.lha / backclock / sources / style / hchoice.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-08-16  |  2.3 KB  |  95 lines

  1. #include <stdio.h>
  2. #include <intuition/intuition.h>
  3. #include <intuition/screens.h>
  4. #include <libraries/gadtools.h>
  5. #include <clib/intuition_protos.h>
  6. #include <clib/exec_protos.h>
  7. #include <clib/graphics_protos.h>
  8. #include <clib/rtracker_protos.h>
  9. #include <clib/exec_protos.h>
  10. #include <clib/dos_protos.h>
  11. #include <clib/gadtools_protos.h>
  12. #include <pragmas/rtracker_pragmas.h>
  13. #include <exec/libraries.h>
  14. #include <exec/memory.h>
  15. #include <exec/ports.h>
  16. #include <dos/dos.h>
  17.  
  18. #include "main.h"
  19. #include "choice.h"
  20. extern struct Library * RTrackerBase ;
  21. extern struct Library * GadToolsBase ;
  22.  
  23. LONG type =0 ;
  24. BOOL stop ;
  25.  
  26. void ProcessWindowCH1( LONG Class, UWORD Code, APTR IAddress ) {
  27.   struct Gadget *gad;
  28.   switch ( Class )
  29.   {
  30.   case IDCMP_GADGETDOWN :
  31.     gad = (struct Gadget *)IAddress ;
  32.     type = NULL ;
  33.     GT_GetGadgetAttrs(gad, CH1, NULL, GTMX_Active, &type) ;
  34.     break ;
  35.   case IDCMP_GADGETUP :
  36.     /* Gadget message, gadget = gad. */
  37.     gad = (struct Gadget *)IAddress;
  38.     switch ( gad->GadgetID )
  39.       {
  40.       case CH1_BUT1 :
  41.         /* Button pressed  , Text of gadget : Save */
  42.         stop = TRUE ;
  43.         break;
  44.       case CH1_BUT2 :
  45.         /* Button pressed  , Text of gadget : Cancel */
  46.         type=-1 ;     // cancel
  47.         stop = TRUE ;
  48.         break;
  49.       }
  50.     break;
  51.   case IDCMP_CLOSEWINDOW :
  52.     /* CloseWindow Now */
  53.     type=-1 ;
  54.     stop = TRUE ;
  55.     break;
  56.   case IDCMP_REFRESHWINDOW :
  57.     GT_BeginRefresh( CH1);
  58.     /* Refresh window. */
  59.     RendWindowCH1( CH1, CH1VisualInfo );
  60.     GT_EndRefresh( CH1, TRUE);
  61.     GT_RefreshWindow( CH1, NULL);
  62.     RefreshGList( CH1GList, CH1, NULL, ~0);
  63.     break;
  64.   }
  65. }
  66.  
  67. LONG choice() {
  68.   ULONG class,
  69.         code ;
  70.   struct Gadget * pgsel ;
  71.   struct IntuiMessage * imsg ;
  72.   stop = FALSE ;
  73.  
  74.   if (!OpenWindowCH1()) {
  75.     /* open the window
  76.      */
  77.     do {
  78.       WaitPort(CH1->UserPort) ;
  79.       while(imsg = GT_GetIMsg(CH1->UserPort)) {
  80.         /* got a message
  81.          */
  82.         class = imsg->Class ;
  83.         code  = imsg->Code ;
  84.         pgsel = (struct Gadget*)imsg->IAddress ;
  85.         GT_ReplyIMsg(imsg) ;
  86. //        printf("Class: %x Code: %ld\n Gad: %x\n", class, code, pgsel) ;
  87.         ProcessWindowCH1(class, code, pgsel) ;
  88.       }
  89.     }while(!stop) ;
  90.     CloseWindowCH1() ;
  91.   }else
  92.     printf("Can't open window\n") ;
  93.   return(type) ;
  94. }
  95.